define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'finance/summary/index' + location.search,
                    add_url: 'finance/summary/add',
                    edit_url: 'finance/summary/edit',
                    del_url: 'finance/summary/del',
                    multi_url: 'finance/summary/multi',
                    import_url: 'finance/summary/import',
                    table: 'order',
                }
            });

            var table = $("#table");

            //当表格数据加载完成时
            table.on('load-success.bs.table', function (e, data) {
                $(".btn-primary-light span").text('￥'+data.all);
            });

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                searchFormVisible: false,
                showToggle: false,
                showColumns: false,
                search: false,
                showExport: false,
                showSearch: false,
                columns: [
                    [
                        {field: 'hotel.hotel_name', title: __('Hotel.hotel_name'), operate: false},
                        {field: 'all_people', title: __('结算总人数'), operate: false},
                        {field: 'all_time', title: __('结算总时长（h）'), operate: false},
                        {field: 'total_price', title: __('结算总金额（元）'), operate: false},
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});